<%-- 
    Document   : afficherlivres
    Created on : 4-Apr-2012, 10:10:13 PM
    Author     : James
--%>

<%@page import="application.MembreBean"%>
<%@page import="application.LivreBean"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="controleur.ConstantesWeb"%>
<%@page import="application.Facade"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Livres</title>
        <link rel="stylesheet" type="text/css" href="<%=ConstantesWeb.CSS_ENTETE%>"/>
    </head>
    <body>
        <%
            
        %>
        <jsp:include page="<%=ConstantesWeb.PAGE_ENTETE%>"/>
        <h1 align="center">Livres</h1>
        <%
            Facade f = new Facade(); 
            List<LivreBean> livresBeanList = (ArrayList<LivreBean>) request.getAttribute(ConstantesWeb.VALEUR_LIVRES_LISTE);

            if (livresBeanList.isEmpty()) {
                out.print("<h2>Il n'y a pas de livres.</h2>");
                return;
            }

            for (LivreBean l : livresBeanList) {%>                
        <table width="850" align="center" cellspacing="0" cellpadding="4" border="1">                                
            <tr>
                <td>
                    <div style="float:left">
                        <%=l.getTitre()%>                        
                    </div>
                    <div style="float:right"><%=f.getCoteMoyenne(l.getIsbn())%></div>
                </td>
            </tr>
            <tr>
                <td>
                    <table width="100%">                        
                        <tr>
                            <td width="100" align="center">
                                <FORM name="<%=ConstantesWeb.CMD_IMAGE%>-<%=l.getIdImage()%>" METHOD="POST" ACTION="./Entree">
                                    <input type="hidden" name="idImage" value="<%=l.getIdImage()%>"/>
                                    <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_IMAGE%>"/>

                                    <a href="#" onclick="document.forms['<%=ConstantesWeb.CMD_IMAGE%>-<%=l.getIdImage()%>'].submit();">
                                        <img src="./<%=ConstantesWeb.PAGE_IMAGE%>?<%=ConstantesWeb.VALEUR_IMAGE_ID%>=<%=l.getIdImage()%>" height="100" width="100" align="center"/>
                                    </a>
                                </FORM> 
                            </td>
                            <td align="justify">
                                <%=l.getDescription()%>
                                <br><br>
                                État : 
                                <%
                                    String etat = f.getTypeValeur(l.getIdEtat());

                                    out.print("<font color=\"");

                                    if (etat.equalsIgnoreCase("disponible")) {
                                        out.print("green\"> ");
                                    } else {
                                        out.print("red\"> ");
                                    }
                                    out.print(etat + "</font>");
                                %>
                            </td>
                            <td width="100" align="center">
                                <FORM name="<%=ConstantesWeb.CMD_LIVRE%>" METHOD="POST" ACTION="./Entree">
                                    <input type="hidden" name="isbn" value="<%=l.getIsbn()%>"/>
                                    <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_LIVRE%>"/>
                                    <button>Détails</button>
                                </FORM>
                            </td>
                        </tr>                                
                    </table>
                </td>
            </tr>                                    
        </table>
        <br>
        <%
            }
        %>
    </body>
</html>
